#include <bits/stdc++.h>
// 2025/01/21
// tag: 
// Author: Zhang Muen
using namespace std;

int primes[10000], a, b, p, parents[100001];
bool is_prime[100001];
class UF
{
public:
    int cnt;

    UF(int n)
    {
        cnt = n + 1;
        for (int i = 0; i <= n; i++)
            parents[i] = i;
    };

    int find(int i)
    {
        if (parents[i] != i)
            return parents[i] = find(parents[i]);
        return parents[i];
    }

    void un(int i, int j)
    {
        int ri = find(i), rj = find(j);
        if (ri == rj)
            return;
        parents[ri] = rj;
        cnt--;
    }

    int count()
    {
        return cnt;
    }

    bool connected(int p, int q)
    {
        return find(p) == find(q);
    }
};
int sieve(void) {
    UF uf(b - a);
    is_prime[0] = is_prime[1] = true;
    for (int i = 2; i <= b; ++i) {
        if (!is_prime[i]) {
            for (int j = i * 2; j <= b; j += i) {
                if (i >= p && j - i >= a)
                    uf.un(j - a, j - i - a);
                is_prime[j] = true;
            }
        }
    }
    return uf.count();
}



signed main()
{
    cin >> a >> b >> p;
    cout << sieve();
    return 0;
}